package com.mybatis.test.spring.mapper;

import com.mybatis.test.spring.entities.User;
import org.apache.ibatis.annotations.*;
import org.mybatis.caches.ehcache.EhcacheCache;
import org.springframework.stereotype.Repository;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author Administrator
 * @create 2020-08-13 11:03
 */
@Repository
@CacheNamespace(implementation = EhcacheCache.class)
public interface UserMapper {
    @Select("SELECT id, name, age, birth FROM user WHERE id = #{userId}")
    User getUser(@Param("userId") int userId);

    @Insert("insert into user(name, age, birth) values (#{user.name} , #{user.age} , #{user.birth})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertUser(@Param("user") User user);
}
